<script>
if (window.testRunner)
    testRunner.waitUntilDone();

var iframe;
var div;

function start() {
    iframe = document.createElement('iframe');
    iframe.src='resources/stylesheet-move-iframe1.xml';
    document.getElementById('store_div').appendChild(iframe);
    window.setTimeout('startrly()', 100);
}

function startrly() {
    if (location.hash == '#done') {
        document.write('PASS');
        if (window.testRunner) {
            testRunner.dumpAsText();
            testRunner.notifyDone();
        }
        return;
    }
    var count = 0;
    if (location.hash !== "")
        count = parseInt(location.hash.substr(1));
    if (count < 10) {
        ++count;
        location.hash = '#' + count;
    } else {
        location.hash = 'done';
    }
    div = document.createElement('div');
    // <marquee> is special as it is implemented using Blink-in-JS (JS code runs for
    // creating a custom element and a shadow root) and invokes its attachedCallback
    // from C++ code, which can cause a special race condition with reloading when
    // it is moved between different documents.
    var marquee = document.createElement('marquee');
    document.body.appendChild(marquee);
    document.body.scrollIntoView(false);

    var iframe2 = document.createElement('iframe');
    iframe2.src = 'resources/stylesheet-move-iframe2.html';
    document.body.appendChild(iframe2);

    document.body.appendChild(iframe.contentDocument.firstChild);
    div.appendChild(marquee);
    window.setTimeout('location.reload();',20);
}
</script>
<body onload="start()">
<div id="store_div"></div>
</script>
